package com.example.springboot_test.service.impl;

import com.example.springboot_test.dao.AuthorsDao;
import com.example.springboot_test.entity.Authors;
import com.example.springboot_test.service.AuthorsService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * (Authors)表服务实现类
 *
 * @author makejava
 * @since 2025-10-22 14:21:37
 */
@Service("authorsService")
public class AuthorsServiceImpl implements AuthorsService {
    @Resource(name = "authorsDao")
    private AuthorsDao authorsDao;

    /**
     * 通过ID查询单条数据
     *
     * @param authorId 主键
     * @return 实例对象
     */
    @Override
    public Authors queryById(Integer authorId) {
        return this.authorsDao.queryById(authorId);
    }

    /**
     * 分页查询
     *
     * @param authors     筛选条件
     * @param pageRequest 分页对象
     * @return 查询结果
     */

    /**
     * 新增数据
     *
     * @param authors 实例对象
     * @return 实例对象
     */
    @Override
    public Authors insert(Authors authors) {
        this.authorsDao.insert(authors);
        return authors;
    }

    /**
     * 修改数据
     *
     * @param authors 实例对象
     * @return 实例对象
     */
    @Override
    public Authors update(Authors authors) {
        this.authorsDao.update(authors);
        return this.queryById(authors.getAuthorId());
    }

    /**
     * 通过主键删除数据
     *
     * @param authorId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer authorId) {
        return this.authorsDao.deleteById(authorId) > 0;
    }
}
